package com.zhm.demo.plugins;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TestFactoryBean implements FactoryBean<TestBean> {

    int count = 0;

    @Override
    public boolean isSingleton() {
        return false;
    }

    @Override
    public TestBean getObject() throws Exception {
        log.error("123");
        if (count > 10) {
            return new TestBean();
        }
        count = count + 1;
        return null;
    }

    @Override
    public Class<?> getObjectType() {
        return TestBean.class;
    }
}
